function menu_close(){
		var boundary_close=document.getElementById("boundary_close");
		var boundary_open=document.getElementById("boundary_open");
		var left=document.getElementById("left");
		var right=document.getElementById("right");
		left.style.width='0px'
		right.style.width='99%';
		boundary_open.style.display='block';
	}
function menu_open(){
	var boundary_close=document.getElementById("boundary_close");
	var boundary_open=document.getElementById("boundary_open");
	var left=document.getElementById("left");
	var right=document.getElementById("right");
	left.style.width='15%'
	right.style.width='83%';
	boundary_open.style.display='none';
}

//模式窗口
function modalDialog(url,w,h){
	r=window.showModalDialog(url,"child","dialogHeight:"+h+"px;dialogWidth:"+w+"px;status:no;scroll:no;help:no");
	
	return r;
}

//获取当前页码url参数
function getRequest() {  
	 var url = location.search; 
	 var theRequest = new Object();  
	 if(url.indexOf("?") != -1){  
	   var str = url.substr(1);  
	     strstrs = str.split("&");  
	   for(var i = 0; i < strstrs.length; i ++)  
	     {  
	      theRequest[strstrs[i].split("=")[0]]=unescape(strstrs[i].split("=")[1]);  
	     }  
	 }  
	 return theRequest;  
}

//form 提交
function fromsubmit(m,op){	
	var form=document.getElementById("myform");
	if(op=='find'){
		form.method='get';	
	}
	form.action='?do='+m+'.'+op;
			
}
//查看
function show_modalDialog(url,w,h){
		var r=modalDialog(url,w,h);
		if(r){window.location=r; }
	}
//删除	
function show_delete(me,url){
	var r=confirm('你确定要删除【'+me+'】吗？');
	if(r){showPage(url);}
}
//通过审核	
function show_pass(me,url){
	var r=confirm('你确定要使【'+me+'】通过审核吗？');
	if(r){showPage(url);}
}

//退出系统	
function logout(url){
	var r=confirm('你确定要退出系统吗？');
	if(r){window.location=url;}
}

function is(obj,id){
	var toobj=document.getElementById(id);
	if(obj.checked==true){
		toobj.disabled=false;
		toobj.style.background='none';
	}else{
		toobj.disabled=true;
		toobj.style.backgroundColor="#eee";
	}
}

//页面跳转
function showPage(url){
	window.location.href=url;
}

//返回
function goHistory(){
	window.history.back(-1);	
}

//登陆框验证
function checkLogin(){
	if($("#username").val()=="")
    {
        alert("用户名不能为空！");
        $("#username").focus();
        return false;
    }
    if($("#password").val()=="")
    {
        alert("密码不能为空！")
        $("#password").focus();
        return false;
    }
    return true;
}

//ajaxForm提交
function loginAjax(){
	 $.post(
		"?do=login.check",
		{
			username:$("#username").val(),
			password:$("#password").val()
		},
		function(data){
			$array = data.split("@@");
			if($array[0]=='false'){
				alert($array[1]);	
			}else{
				showPage($array[1]);
			}
		}                         
	 );
}

//Login提交
function loginSubmit(){
	if(checkLogin()){
		//form提交
		loginAjax();
	}
}

function keydownsearch(evt) 
{ 
	evt = (evt) ? evt : ((window.event) ? window.event : "") 
	keyCode = evt.keyCode ? evt.keyCode : (evt.which ? evt.which : evt.charCode); 
	if (keyCode == 13) { 
		loginSubmit();
		//search();
	} 
}

//级联分类列表(ajax)
function getTypeList(){
	 
	 $.getJSON(
		"?do=news.getTypeList&gameID="+$("#gameID").val(),
		function(data){
			
			var html1 = "";
			
			$.each(data,function(key,value){
				
				html1 = html1 + "<option value='"+value['typeid']+"' >"+value['typename']+"</option>";
				
			});
			
			$("#typeID").html(html1);
		}                         
	 );
}

//分页选择框，跳转页面
function selectChangeUrl(id, url){
	var index = $('#'+id).val();
	showPage(url+'&pageIndex='+index);
}

// preview of kws listing page
function preview(id, host){
	var image = '';
	
	var a = id;
	
	if(a.indexOf("HD") !== -1 )  
	{  
		image = "<iframe src='index.php?do=kws.preview&id="+id+"' style='height: 230px; ' ></iframe>";
	}else{
		image = "<iframe src='"+host+"d/preview.php?id="+id+"' style='height: 500px; width: 500px;' ></iframe>";
	}  
	
	$( "#dialog-modal" ).html(image);
	$( "#dialog-modal" ).dialog({
		height: 290,
		width: 400,
		modal: true
	});
//	 $.post(
//		"?do=kws.showimg",
//		{
//			id:id
//		},
//		function(data){
//			if(data==''){
//				image = "<iframe src='"+host+"d/preview.php?id="+id+"' style='height: 500px; width: 500px;' ></iframe>";
//			}else{
//				image = "<iframe src='index.php?do=kws.preview&id="+id+"' style='height: 230px; ' ></iframe>";
//			}
//			$( "#dialog-modal" ).html(image);
//			$( "#dialog-modal" ).dialog({
//				height: 290,
//				width: 400,
//				modal: true
//			});
//		}                         
//	 );
}

//preview of pic listing page
function previewofpic(id){
	
	var image = "<iframe src='index.php?do=pic.getPicAdsHTML&id="+id+"#target_width=412' style='height: auto; width: 414px;' ></iframe>";
	
	$( "#dialog-modal" ).html(image);
	$( "#dialog-modal" ).dialog({
		height: 'auto',
		width: 600,
		modal: true
	});
}

//preview of pic insert page
function previewofpicinsert(){
	var image = '';
	
	var tpl = encodeURIComponent($("#tpl").val());
	
	var text = encodeURIComponent($("#text").val());
	var text_color = encodeURIComponent($("#text_color").val());
	var text_size = encodeURIComponent($("#text_size").val());
	var content = encodeURIComponent($("#content").val());
	var content_color = encodeURIComponent($("#content_color").val());
	var content_size = encodeURIComponent($("#content_size").val());
	var out_url = encodeURIComponent($("#out_url").val());
	var icon_url = encodeURIComponent($("#pic_url").val());
	var bg_url = encodeURIComponent($("#bg_url").val());
	
	var image = "<iframe src='index.php?do=pic.previewInsert&tpl="+tpl+"&text="+text+"&text_color="+text_color+"&text_size="+text_size+"&content="+content+"&content_color="+content_color+"&content_size="+content_size+"&our_url="+out_url+"&pic_url="+icon_url+"&bg_url="+bg_url+"#target_width=412' style='height: auto; width: 414px;' ></iframe>";
	
	$( "#dialog-modal" ).html(image);
	$( "#dialog-modal" ).dialog({
		height: 'auto',
		width: 600,
		modal: true
	});
	
	 /*$.post(
		"?do=pic.previewInsert",
		{
			text:text,
			text_color:text_color,
			text_size:text_size,
			content:content,
			content_color:content_color,
			content_size:content_size,
			out_url:out_url,
			icon_url:icon_url,
			bg_url:bg_url
		},
		function(data){
			image = data;
			alert(image);
			$( "#dialog-modal" ).html(image);
			$( "#dialog-modal" ).dialog({
				height: 400,
				width: 400,
				modal: true
			});
		}                         
	 );*/
}

//preview of pic insert page
function previewofkwinsert(){
	var image = '';
	
	var text = encodeURIComponent($("#text").val());
	var tpl = encodeURIComponent($("#tpl").val());
	
	var img = encodeURIComponent($("#img").val());
	var img_title = encodeURIComponent($("#img_title").val());
	var img_desc = encodeURIComponent($("#img_desc").val());
	var img_price = encodeURIComponent($("#img_price").val());
	var img_outurl = encodeURIComponent($("#img_outurl").val());
	
	var image = "<iframe src='index.php?do=kws.preview&tpl="+tpl+"&img="+img+"&img_title="+img_title+"&img_desc="+img_desc+"&img_price="+img_price+"&img_outurl="+img_outurl+"' style='height: 500px; width: 500px;' ></iframe>";
	
	$( "#dialog-modal" ).html(image);
	$( "#dialog-modal" ).dialog({
		height: 400,
		width: 400,
		modal: true
	});
	
	/*
	$.post(
			"?do=kws.preview",
			{
				img:img,
				img_title:img_title,
				img_desc:img_desc,
				img_price:img_price,
				img_outurl:img_outurl
			},
			function(data){
				image = data;
				$( "#dialog-modal" ).html(image);
				$( "#dialog-modal" ).dialog({
					height: 400,
					width: 400,
					modal: true
				});
			}                         
		 );
		 */
	
}

// preview of vbc listing page
function previewofvbc(id){
	var image = '';
	
	 $.post(
		"?do=vbc.showimg",
		{
			id:id
		},
		function(data){
			if(data!=''){
				var idArr = data.split(",");
				for(var i=0; i<idArr.length; i++ ){
					var info = idArr[i].split("@@");
					image += "名称："+info[1]+"<br />";
					image += "<iframe src='/d/preview.php?id="+info[0]+"' style='height: 260px; width: 500px;' ></iframe><br />";
				}
			}
			$( "#dialog-modal" ).html(image);
			$( "#dialog-modal" ).dialog({
				height: 500,
				width: 600,
				modal: true
			});
		}                         
	 );
}

// redirect page 
function go(url){
	location.href = url;
}

function checkAll(id){
	if($("#"+id).attr("checked") ){
		$('input[type=checkbox][name=checkbox_name]').each(function() {
			   $(this).attr("checked", true);
		});
	}else{
		$('input[type=checkbox][name=checkbox_name]').each(function() {
			   $(this).attr("checked", false);
		});
	}
}

function getCheckboxValue(name){
	var cbxVehicle = new Array();
	var i=0;
	$(":checkbox[name='"+name+"']:checked").each(function() {
		if(this.checked){
			cbxVehicle[i] = this.value;
			i++;
		}
	});
	var txt = cbxVehicle.join(",");
	return txt;
}

function checkLength() {  
	var text = $('#content');
	var maxChars = 30;  
	
	var textVal = text.val();
	textVal = textVal.replace(/[^\x00-\x80]/g, '11');	
	var vLength = textVal.length;
	
	if (textVal.length > maxChars * 2){
		var v = text.val();
		v = v.substring(0, maxChars); 
		text.val(v);
	}
	var curr = maxChars - Math.round(vLength/2);
	if(curr<0)curr=0;
	$("#inputNumber").html("还可以输入 "+curr.toString()+" 汉字！");  
}

function checkTitleLength() {  
	var text = $('#text');
	var maxChars = 20;  
	
	var textVal = text.val();
	textVal = textVal.replace(/[^\x00-\x80]/g, '11');	
	var vLength = textVal.length;
	
	if (textVal.length > maxChars * 2){
		var v = text.val();
		v = v.substring(0, maxChars); 
		text.val(v);
	}
	var curr = maxChars - Math.round(vLength/2);
	if(curr<0)curr=0;
	$("#inputTitleNumber").html("还可以输入 "+curr.toString()+" 汉字！");  
}

function checkKWcontentLength() {  
	var text = $('#img_desc');
	var maxChars = 24;  
	
	var textVal = text.val();
	textVal = textVal.replace(/[^\x00-\x80]/g, '11');	
	var vLength = textVal.length;
	
	if (textVal.length > maxChars * 2){
		var v = text.val();
		v = v.substring(0, maxChars); 
		text.val(v);
	}
	var curr = maxChars - Math.round(vLength/2);
	if(curr<0)curr=0;
	$("#inputNumber").html("还可以输入 "+curr.toString()+" 汉字！");  
}